The present invention relates to a method and apparatus for operating a network server in a network environment, and more particularly relates to a method and apparatus for interfacing with a stateless NFS (Network File System) server.
In a typical network environment, a plurality of network clients are coupled to one or more network servers for accessing files in the network server. When an application program in a network client executes, it calls an operating system in the network client to open a file, or to store and retrieve data in files. A file access mechanism in the network client accepts the request and automatically passes it either to local file system software or to NFS client software in the network client, depending on whether the file is on the local disk or on a remote network server. When it receives a request from the file access mechanism, the NFS client software uses the NFS protocol to contact the remote network server to perform the requested operation and return results to the NFS client software. When the remote network server replies, the NFS client software returns the results to the application program in the network client.
The NFS protocol is defined in various standards documents, e.g., "NFS: Network File System Protocol Specifications," Sun Microsystems, Inc., RFC (Request for Comment) 1094, which is hereby incorporated by reference. The NFS protocol requires a "stateless server." This means that the state of interactions between the server and a client are not to be tracked or managed by the server during a session. Thus, if a client makes a request to a server, and after satisfying that request the server fails and is restarted, the server must be able to handle subsequent related requests from the client without needing to access state data that was lost when the server failed.
In general, this statelessness is achieved because each request has sufficient information to completely define the request. Whatever state is required is saved in the client and passed to the server with each request. In particular, the NFS protocol defines a data structure called a "file handle." The file handle contains sufficient information to uniquely identify the file to be accessed. The advantage and purpose of a stateless server is to improve robustness by being able to continue file access in spite of the failure and restart of the file server.
However, traditional file access, and therefore the operating-system mechanisms to support it, are "stateful," i.e., there is state information saved in the file system about a file from the time file access begins (via an open system call) until file access is terminated (via a close system call). Thus, there are problems associated with implementing a stateless file server. On many operating systems, to have to recreate this state information for each read or write operation adds significant system overhead and reduces system performance to an unacceptable degree.
An additional problem of conventional systems has to do with specifying how a file is to be accessed. This is mainly important for security checking to determine the file access privilege that is permitted for a particular request. In a typical operating system, the "open" system call specifies whether the request needs read access, write access or both. Since there is no open request in the NFS protocol, there is no way for the server to know the access intentions of the client, other than by the READ and WRITE requests that it makes to the server. The simple solution is to always assume both read and write access. However, if the access intention is for read-only, both read and write access is granted. Requesting write access to a file can cause problems, such as a disk process in the server restricting the caching of data for that file in other CPUs. This restriction has a negative impact on performance and should be avoided. Moreover, opening a file for write access also possibly locks out, for that file, other file openers in the operating system for the duration of that open.
Therefore, there exists a need for an improved method and apparatus for interfacing with a stateless NFS server that reduces unnecessary system overhead and enhances system performance.